/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.router.facade.order.virtualaccount;

import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import info.peigen.hotpot.business.router.facade.enums.ChannelCode;
import info.peigen.hotpot.business.router.facade.order.AbstractRouterServiceOrder;
import info.peigen.hotpot.common.core.enums.Currency;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import lombok.experimental.SuperBuilder;

/**
 * <b>(CreateVirtualAccountOrder)</b>
 * 创建虚拟账户
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/8/12
 */
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
@Data
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
public class CreateVirtualAccountOrder extends AbstractRouterServiceOrder {
    @NotNull
    ChannelCode code;
    /** 虚拟账户名 */
    @NotEmpty
    String      virtualAccountName;
    /** 币种 */
    Currency currency;

    @Override
    public void check() {
        switch (code) {
            case Pingan:
                Assert.isTrue(StrUtil.length(virtualAccountName) <= 80, "HK的虚拟账户名长度必须小于80个字符");
                Assert.isTrue(ObjectUtil.isNull(currency) || currency == Currency.ALL);
                break;
            default:
                break;
        }
    }
}
